package indi.zhang.framework.entity.userModule;


import cn.hutool.core.lang.RegexPool;
import com.baomidou.mybatisplus.annotation.SqlCondition;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonProperty;
import indi.zhang.framework.base.mybatis.BaseEntity;
import indi.zhang.framework.constant.Regular;
import indi.zhang.framework.validation.Save;
import indi.zhang.framework.validation.Update;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;

/**
 * 总后台用户表(User)表实体类
 *
 * @author jy
 * @since 2022-01-17 12:08:34
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class User extends BaseEntity {

	private static final long serialVersionUID = -991183859355000223L;

	/**
	 * 账户
	 */
	@NotBlank(message = "账户不能为空", groups = Save.class)
	@JsonProperty("acc")
	private String account;

	/**
	 * 密码
	 */

	@NotBlank(message = "密码不能为空", groups = Save.class)
	@Pattern(regexp = Regular.PASSWORD, message = Regular.PASSWORD_MASSAGE, groups = {Save.class, Update.class})
	@JsonProperty(value = "pwd", access = JsonProperty.Access.WRITE_ONLY)
	private String password;

	/**
	 * 姓名
	 */

	@TableField(condition = SqlCondition.LIKE_RIGHT)
	@Length(max = 10, groups = {Save.class, Update.class})
	@NotBlank(message = "姓名不能为空", groups = Save.class)
	@JsonProperty("nick")
	private String name;

	/**
	 * 邮箱
	 */
	@Email(message = "请输入正确邮箱格式", groups = {Save.class, Update.class})
	@JsonProperty("mail")
	private String email;

	/**
	 * 手机号码
	 */
	@Pattern(regexp = RegexPool.MOBILE, message = "请输入正确手机格式", groups = {Save.class, Update.class})
	@JsonProperty("number")
	private String phone;

	/**
	 * 是否为内置
	 */
	@JsonProperty("init")
	private Boolean initial;

	/**
	 * 是否启用 1 启用 0 禁用
	 */
	@JsonProperty("ena")
	private Boolean enable;

}

